<!DOCTYPE html>
<html lang="zh-CN">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>组件中的数据存放问题</title>
</head>

<body>

  <div id="app">
    <!-- 创建三个组件实例 -->
    <counter></counter>
    <counter></counter>
    <counter></counter>
  </div>


  <template id="counter">
    <div>
      <h3>当前计数: {{ count }}</h3>
      <button @click="count--" :disabled="count==0">-</button>
      <button @click="count++">+</button>
    </div>
  </template>


  <script src="../../js/vue.js"></script>
  <script>
    const app = new Vue({
      el: '#app',
      components: {
        counter: {
          template: '#counter',
          data() {
            return {
              count: 0
            }
          }
        }
      }
    })
  </script>
</body>

</html>